#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1e5 + 10;
int t, n, m, l, lv;
//n cars, m ce_su_yi, length of road, limit v of road
struct node{
    ll d, v, a;
}car[maxn];
//car southest distance, ..., ..., 
ll p[maxn];
//ce_su_yi southest distance
int sum1, sum2;
/*int zuijin(int tmp){
    for(int i = 1; i <= m; i++)
        if(p[i] >= car[tmp].d)
            return i;
}*/
int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> t;
    while(t--)
    {
        cin >> n >> m >> l >> lv;
        for(int i = 1; i <= n; i++) 
            cin >> car[i].d >> car[i].v >> car[i].a;
        for(int i = 1; i <= m; i++)
            cin >> p[i];
        for(int i = 1; i <= n; i++)
        {
            if(car[i].a == 0)
            {
                if(car[i].v <= lv)  continue;
                else sum1++;
            }
            /*if(car[i].a < 0)
            {
                if(car[i].v <= lv)  continue;
                ll vv = car[i].v * car[i].v - fabs(2 * car[i].a * (p[ zuijin(i) ] - car[i].d));
                if(vv > (lv * lv)) sum1++;
            }
            if(car[i].a > 0)
            {
                ll vv = car[i].v * car[i].v + fabs(2 * car[i].a * (p[m] - car[i].d));
                if(vv > (lv * lv)) sum1++;
            }*/
        }
        cout << sum1 << ' ' << m-1 << '\n';
    }
    return 0;
}